<template>
  <div class="newsDetails">
    <!-- 头部 -->
    <InsideHeader :bannerType="bannerType"></InsideHeader>

    <!-- 面包屑 -->
    <!-- <crumb></crumb> -->
    <div class="crumb">
      <div class="block">
        <div class="crumbL">
          <nuxt-link :to="{name: 'index'}">首页</nuxt-link>
          <em>></em>
          <nuxt-link :to="{name: 'news-newsIndex'}">最新资讯</nuxt-link>
          <em>></em>
          <nuxt-link :to="{name: 'news-newsCompany'}">公司新闻</nuxt-link>
          <em>></em>
          <nuxt-link :to="{name: 'news-newsDetails'}" class="on">详情</nuxt-link>
          <div class="clear"></div>
        </div>
        <!-- <div class="crumbR">
                <nuxt-link :to="{name: 'news-newsCompany'}">公司新闻</nuxt-link>
              <nuxt-link :to="{name: 'news-newProduct'}">新品发布</nuxt-link>
              <nuxt-link :to="{name: 'news-logUpdate'}">资料更新日志</nuxt-link>
                <div class="clear"></div>
        </div>-->
        <div class="clear"></div>
      </div>
    </div>

    <div class="newsDetailsCon">
      <div class="block">
        <div class="content">
          <div class="title">
            <p>{{newsinfo.title}}</p>
            <div>
              <img src="../../static/newsImg/time.png" />
              <span>{{newsinfo.createTime}}</span>
            </div>
          </div>
          <div v-html="contents" class="conten"></div>
        </div>
      </div>
    </div>

    <div class="addcollect">
      <span @click="Collect">
        <img src="../../static/icons/Collect.png" width="20" />
        <font>添加收藏</font>
      </span>
      <div class="clear"></div>
    </div>

    <!-- 链接 -->
    <Insidelink></Insidelink>

    <!-- 底部 -->
    <HomeHooter></HomeHooter>
  </div>
</template>

<script>
import $ from "jquery";
import "@/assets/css/news.css";
import InsideHeader from "@/components/head";
import HomeHooter from "@/components/footer";
import crumb from "@/components/crumb";
import Insidelink from "@/components/link";
import Qs from "qs";

export default {
  name: "newsDetails",
  data() {
    return {
      bannerType: "news",
      id: "", //id
      newsinfo: "", //详情
      contents: "" //富文本
    };
  },
  components: {
    InsideHeader,
    HomeHooter,
    crumb,
    Insidelink
  },
  methods: {
    //详情
    newsInfo() {
      let id = this.$axios,
        params = {
          oid: this.$route.query.id
        };
      this.$api.homeindex.newsinfo(id, params).then(res => {
        let result = res.data;
        if (result.code === 1) {
          this.newsinfo = result.data;
          this.contents = result.data.content;
        }
      });
    },

    // 添加收藏
    Collect() {
      console.log("0000");
      let id = this.$axios;
      let params = {
        type: this.newsinfo.type,
        relationOid: this.newsinfo.oid,
        title: this.newsinfo.title,
        mainPhoto: this.newsinfo.mainPhoto,
        createBy: "4028818d6ec93de2016ec94c1ec10094"
      };
      // params = Qs.stringify(params);
      this.$api.homeindex.saveSysCollection(id, params).then(res => {
        let result = res.data;
        if (result.code === 1) {
          this.$message({
            message: result.msg,
            type: "success"
          });
        } else {
          this.$message({
            message: result.msg,
            type: "warning"
          });
        }
      });
    }
  },
  created() {
    //详情
    this.newsInfo();
  }
};
</script>

<style scoped>
.addcollect {
  width: 85%;
  margin: 20px auto;
}
.addcollect span {
  float: right;
  color: #ee4e5b;
  font-size: 14px;
  cursor: pointer;
}
.addcollect font,
.addcollect img {
  float: left;
}
.conten {
  font-size: 14px;
  line-height: 25px;
  margin-top: 30px;
}
</style>
